package Core;

import java.awt.Color;
import java.awt.image.BufferedImage;

import Engine.Engine;
import Engine.GUI.Button;
import Engine.TileHandling.Tile;
import Engine.TileHandling.TileGraphics;
import Engine.Utils.ImageHandler;
import Engine.Utils.Vector2f;

/**
 * This is the main class of the game.
 * @author Lueko
 *
 */
public class Core extends Engine {

    private static final long serialVersionUID = 1L;
    
    private BufferedImage[][] images;

    public Core(String title, int width, int height, String mapPath) {
        super(title, width, height, mapPath);
        
        images = ImageHandler.splitImageMap(ImageHandler.load("/entities/Enemies1.png"), 32, 32);
        
//        new Mob(new Vector2f(width / 2, height / 2), images[0], false, true).add();
        new Button(images[0][0], new Vector2f(width / 2, height / 2)).add();
        
        addTiles();
    }
    
    public static void main(String[] args) {
        new Core("Engine-Test", 800, 600, "/maps/asdfmap.png");
    }
    
    int time = 0;
    
    @Override
    protected void updateStuff() {
        time++;
        if (time >= 60) {
            window.setTitle(window.getRealTitle() + " | " + fps + "fps | " + ups + "ups");
            time = 0;
        }
    }
    
    /**
     * Specifies all tiles and adds them to the TileRenderer.tiles array.
     */
    private void addTiles() {
        new Tile(new TileGraphics(32, 32, Color.DARK_GRAY), 0xff000000, true);
        new Tile(new TileGraphics(32, 32, Color.LIGHT_GRAY), 0xffffffff, true);
        new Tile(new TileGraphics(32, 32, Color.GREEN), 0xff00ff00, true);
    }
    
}
